package com.achao.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author: achao
 * @DateTime: 2022/10/16 10:22
 * @Description: TODO
 */
@RestController
@RequestMapping("/sentinel")
public class HelloController {

    @GetMapping("/hello")
    public String hello() {
        return "hello sentinel alibaba";
    }

    @GetMapping("/flow")
    @SentinelResource(value = "flow",blockHandler = "flowBlockHandler")
    public String flow(){
        return "正常访问";
    }

    public String flowBlockHandler(BlockException e) {
        return "流控";
    }

    @GetMapping("/global")
    public String global(){
        return "正常访问";
    }

}
